Similarly go ahead with the user details
for fetching and adding the data. Use app dot post with the user and
brackets Add a try block and provide the attributes
of the user under the block. The request that body sends the request. To validate the data give
the following command, if not email, user name,
password and watch list. Send response status to 400 and show that all the inputs are required. Use an existing consistent user and
find one method for another email based validation. Give statement if existing user. This statement returns a status of 409 and
show the user already exists. The statement mentioned also
saves the user in the database. Use a constant user to create Also used data, time and a user ID. The create token followed by the user dot
token is equal to the token that we have. The token will be generated. The token will return the status of 201,
if the user is saved. But if the user already exists,
the token will return a status of 409. Finally import the module as app. You have learned to implement
the logic related to adding the movie details along with the user
details based on the JWT token. The user and movie references are taken,
followed by the token. After that you have implemented
the logic for adding and fetching the movie details as well as
user details with the proper validation. Now you will learn to write
code inside the index dot JS. Navigate to the index dot JS file and
implement the code inside the file. The index dot JS file requires
reference to http and the app. Implement the server by instantiating
the server object as an http dot create server with an app reference
to create the server for the app. Now specify the reference for the route
that redirects the route to the app. Also provide the support number,
that is 4001, on which the server will run,
choose the pork number of your choice Activate the server so
that runs on mentioned report. Similarly open the app dot
test dot Js file to write the code to test the execution status. This step is not mandatory with respect
to creating the micro service but it's for reference. At a reference that is a rest
underscore super set and have should after that create a test
suit through the describe function. The test cases,
verify the test of the movie service and the user service to get the response
based on the servers working status. Implement the user service related cases Before the implementation step,
add two more dependencies. Super test and
should under the commands NPM install. Super test hyphen hyphen save and NPM install should hyphen hyphen
save to add the dependencies Execute the code through
the NPM start command. You can See that the server
is running on Port 4001 and successfully connected to the movie
database message in the output. The movie database movie DB is
created inside the movie you are l based on the models. Movie and user check for test cases
whether commands are passing or not. By using the statement NPM test, you can see that all five test
cases are flawlessly running. In this way, you can create
a micro service using NO Js and test the micro service by
using the post method. Thank you.